﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="background: #909090;">
<head runat="server">
    <title>欢迎使用重庆文理学院在线考试系统</title>
    <link rel="icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/ligerUI/skins/Aqua/css/ligerui-dialog.css" rel="stylesheet" type="text/css" />

    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

    <script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>

    <script src="../../Scripts/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>

    <script src="../../Scripts/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>

</head>
<body>
    <div class="login">
        <div class="input_panel">
            <div class="top">
            </div>
            <div class="mid">
                <form id="form_login" action="/home/login" method="post">
                <table>
                    <tr>
                        <td align="right">
                            账号：
                        </td>
                        <td>
                            <input id="account"  name="account" class="account" type="text" tabindex="1"/>
                        </td>
                        <td rowspan="5">
                            <input class="btn_login" type="submit" value="登&nbsp;录" tabindex="8"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            密码：
                        </td>
                        <td>
                            <input id="pwd" name="pwd" class="pwd" type="password" tabindex="2"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            身份：
                        </td>
                        <td>
                            <input type="radio" id="role_t" name="role" checked="checked" value="zg" tabindex="3"/>
                            <label for="role_t">
                                职工</label>
                            <input type="radio" id="role_s" name="role" value="xs" tabindex="4"/>
                            <label for="role_s">
                                学生</label>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            验证码：
                        </td>
                        <td>
                            <input id="vcode" name="vcode" class="vcode" type="text" tabindex="5"/>
                            <img title="点击更换" alt="验证码" src="/Home/ValidateImg" class="vcode" tabindex="6"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <font color="#E8EEF4">若忘记了密码，请与管理员或辅导员联系</font>
                        </td>
                    </tr>
                </table>
                </form>
            </div>
            <div class="bot">
            </div>
        </div>
        <div class="earth">
        </div>
    </div>

    <script type="text/javascript" language="javascript">

        $(document).ready(function() {

            $('img.vcode').click(function() {
                $(this).attr('src', '/Home/ValidateImg?ver=' + Math.ceil(Math.random() * 899 + 100));
            });

            $("#form_login").validate({
                rules: {
                    account: {
                        required: true
                    },
                    pwd: {
                        required: true
                    }
                },
                messages: {
                    account: {
                        required: "*"
                    },
                    pwd: {
                        required: "*"
                    }
                }
            });

            $("#form_login").submit(function() {
                var isValid = $(this).valid();
                var code = $.trim($('#vcode').val());
                if (isValid) {
                    if (code == '') {
                        $.ligerDialog.warn('请输入验证码');
                        return false;
                    }

                    $.ajax({
                        type: 'post',
                        url: '/home/validatecode',
                        async: false,
                        data: { code: code },
                        success: function(result) {
                            isValid = result;
                            if (!result) {
                                $.ligerDialog.error('验证码错误');
                                $('img.vcode').click();
                            }
                        }
                    });

                    return isValid;
                }
            });
        });
    </script>

</body>
</html>
